import type {RouteLocationNormalized} from "vue-router";

export const routes = [
    {
        path: '/',
        redirect: '/index/home'
    },
    {
        path: '/index',
        name: 'index',
        component: () => import('@/pages/index.vue'),
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('@/pages/Home/index.vue')
            },
            {
                path: 'search',
                name: 'search',
                component: () => import('@/pages/Search/index.vue'),
                props: (to: RouteLocationNormalized) => to.query
            },
            {
                path: 'detail/:skuId',
                name: 'detail',
                component: () => import('@/pages/Detail/index.vue'),
                props: true
            },
            {
                path: 'shop-cart',
                name: 'shop-cart',
                component: () => import('@/pages/ShopCart/index.vue'),
            },
            {
                path: 'shop-cart/success',
                name: 'addCartSuccess',
                component: () => import('@/pages/ShopCart/Success.vue'),
                props: (to: RouteLocationNormalized) => to.query,
            }
        ],
    },

    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/Login/index.vue')
    },
    {
        path: '/register',
        name: 'register',
        component: () => import('@/pages/Register/index.vue')
    },

]
